def find_all(seq :str, sub_seq :str):
	n_all = len(seq)
	n_sub = len(sub_seq)
	res = []
	for ind in range(n_all - n_sub):
		if seq[ind:ind+n_sub] == sub_seq:
			res.append(ind)
	return res

if __name__ == '__main__':
	# load all header folders
	str_headers = open('headers_input.txt', 'rt').read(-1)
	# seperate each with double-quote marks
	ids = find_all(str_headers, '\"')
	assert len(ids) % 2 == 0
	headers = [str_headers[ids[2*i]+1:ids[2*i+1]] for i in range(len(ids)//2)]
	out_headers = ''
	for i in range(len(headers)-1):
		out_headers += headers[i] + ','
	out_headers += headers[-1]
	open('headers_output.txt', 'wt').write(out_headers)
		
	
